import { ShellIntegration } from './app/services/shellIntegration';
import {version} from "./assets/version.json"
/*
 * Angular bootstraping
 */
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { decorateModuleRef } from './app/environment';
import { bootloader } from '@angularclass/hmr';
/*
 * App Module
 * our top level module that holds all of our components
 */
import { AppModule } from './app';

/*
 * Bootstrap our Angular app with a top level NgModule
 */

console.log(`version: ${version}`)
export function main(): Promise<any> {
  return platformBrowserDynamic()
    .bootstrapModule(AppModule)
    .then(decorateModuleRef)
    .then(moduleRef => {
      const shellIntegration: ShellIntegration = moduleRef.injector.get(ShellIntegration);
      window['kdsReceiveMessage'] = shellIntegration.receiveMessage.bind(shellIntegration);
    })
    .catch(err =>  console.error(err));
}

// needed for hmr
// in prod this is replace for document ready
bootloader(main);
